export default {
  // 切换登录状态
  changeLoginShow (state, bool) {
    state.loginShow = bool
  },
  // 切换前后端显示状态
  changeSystemShow (state, bool) {
    state.systemShow = bool
  },
  // 将页面加入keep-alive
  keepIn (state, keepCommponent) {
    state.includes.push(keepCommponent)
  },
  // 将页面从keep-alive中除去
  keepOut (state) {
    state.includes = []
  },
  // 设置高度
  setWrapHeight (state, h) {
    state.gHeight = h
  },
  // loading次数累加
  addLoadingCount (state) {
    state.loadingCount++
  },
  // loading次数递减
  minusLoadingCount (state, count) {
    state.loadingCount--
    if (state.loadingCount <= 0 || count === 0) {
      state.loadingCount = 0
    }
  },
  // 展示loading
  showLoading (state) {
    // loading的配置项
    const loadingOpts = {
      lock: true,
      text: '拼命加载中...',
      spinner: 'el-icon-loading',
      background: 'rgba(0, 0, 0, 0.7)',
      customClass: 'el-loading-mask-full'
    }
    this.commit('addLoadingCount')
    state.loadingCont = this._vm.$loading(loadingOpts)
  },
  // 隐藏loading
  hideLoading (state, count) {
    this.commit('minusLoadingCount', count)
    if (state.loadingCount < 1) {
      state.loadingCont.close()
    }
  }
}
